# Maintainer: Bruno Pagani <archange@archlinux.org>

pkgname=ospray
pkgver=2.12.0
pkgrel=1
pkgdesc="Ray Tracing Based Rendering Engine for High-Fidelity Visualization"
arch=(loong64 x86_64)
url="https://www.ospray.org/"
license=(Apache)
depends=(
  embree
  gcc-libs
  glibc
  ispc
  onetbb
  openmpi
  openimagedenoise
  openvkl
  rkcommon
  snappy
)
makedepends=(
  cmake
  benchmark
  glu
  gtest
  level-zero-headers
  level-zero-loader
)
optdepends=('benchmark: benchmarks'
            'gtest: tests suite')
source=(https://github.com/ospray/OSPRay/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('268b16952b2dd44da2a1e40d2065c960bc2442dd09b63ace8b65d3408f596301')

build() {
  local cmake_options=(
    -B build
    -DCMAKE_BUILD_TYPE=Release  # None is not supported :(
    -DCMAKE_INSTALL_PREFIX=/usr
    -DCMAKE_INSTALL_LIBDIR=lib
    -DOSPRAY_BUILD_ISA=ALL
    -DOSPRAY_ENABLE_APPS_EXAMPLES=OFF
    -DOSPRAY_ENABLE_APPS_TUTORIALS=OFF
    -DOSPRAY_ENABLE_MODULES=ON
    -DOSPRAY_MODULE_DENOISER=ON
    -DOSPRAY_MODULE_MPI=ON
    -S $pkgname-$pkgver
    -W no-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

check() {
  ctest --test-dir build --output-on-failure
}

package() {
  DESTDIR="$pkgdir" cmake --install build
}
